<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        
        <el-col :span="8">
            <el-form-item label="所属教学楼">
              <el-select v-model="dataForm.FPARENTNO" placeholder="请选择">
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="所属楼层">
              <el-select v-model="dataForm.FLEVEL" placeholder="请选择">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item class="required" label="场地名称" prop="FCATNAME">
              <el-input
                v-model="dataForm.FCATNAME"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

        <el-col :span="8">
            <el-form-item label="负责人">
              <el-select v-model="dataForm.FUSER" placeholder="请选择">
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加场地</el-button> -->
            <el-button type="primary" :loading="loading" @click="closePage">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

   <template>
     <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="预约时间" name="first">
        <el-table :data="list" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FMEMO" label="时段说明" ></el-table-column>
          <el-table-column prop="FBEGTIME" label="开始时间"></el-table-column>
          <el-table-column prop="FENDTIME" label="结束时间" ></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>
      <el-tab-pane label="工位设置" name="second">
        <el-table :data="list2" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FWORKNO" label="工位编号" ></el-table-column>
          <el-table-column prop="FWORKNAME" label="工位名称"></el-table-column>
          <el-table-column prop="FMEMO" label="备注信息" ></el-table-column>
       </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>

      <el-tab-pane label="预约参数" name="third">
        <el-row class="JNPF-common-search-box" :gutter="16">
        <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">

          <el-col :span="8">
            <el-form-item label="收费方式">
              <el-select v-model="dataForm.FCHARETYPE" placeholder="请选择">
                <el-option
                  v-for="item in options4"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
          <el-form-item label="人数限制" prop="FUSENUM">
            <el-input v-model="dataForm.FUSENUM"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="面积(km²)" prop="FSIZE">
            <el-input v-model="dataForm.FSIZE"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="收费标准" prop="FMONEY">
            <el-input v-model="dataForm.FMONEY"   />
          </el-form-item>
        </el-col>

         </el-form>
        </el-row>

      </el-tab-pane>

      <!-- <el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane> -->
      <!-- <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane> -->
    </el-tabs>
  </template>
    
    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        activeName: 'first',
        title: "新增",
        insertorupdate: true,
        dataForm: {
          FPARENTNO :"第二教学楼",
          FLEVEL:"一楼",
          FUSENUM:10,
          FUSER:"项羽",
          FCATNAME: "101教室",
          FMEMO: "有机化学实验操作课",
          FBEGDATE: "2024-12-01",
          FENDDATE: "2025-11-30",
          FCHECKUSE: "汉武帝",
          FBILLSTATE: "申请中",
          FCHECKDATE: "",
          FNOTE: "",
          FCHARETYPE:"不收费",
          FUSENUM:20,
          FSIZE:58,
          FMONEY:0
        },
        rules: {
          FUSERNUMBER:[
            { required: true, message: '请输入学籍号码', trigger: 'blur' },
          ],
          FUSER: [
            { required: true, message: '请输入申请人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入申请理由', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FMEMO": "上课时间",
                  "FBEGTIME": "09:00",
                  "FENDTIME": "11:30"
                },
                { "FENTRYID":2,
                  "FMEMO": "上课时间",
                  "FBEGTIME": "13:30",
                  "FENDTIME": "17:00"
                }],
        list2: [{  "FENTRYID":1,
                  "FWORKNO": "1-1",
                  "FWORKNAME": "1号工位",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FWORKNO": "1-2",
                  "FWORKNAME": "2号工位",
                  "FMEMO": ""
                }],
        loading: false,
        visible: false,

        //所属教学楼选择数据
        options1: [{
          value: '20E01',
          label: '第一教学楼'
        }, {
          value: '20E02',
          label: '第二教学楼'
        }, {
          value: '20N01',
          label: '第一实验楼'
        }, {
          value: '20N02',
          label: '第二实验楼'
        }],

        //所属楼层选择数据
        options2: [{
          value: '20E01',
          label: '一楼'
        }, {
          value: '20E02',
          label: '二楼'
        }, {
          value: '20N01',
          label: '三楼'
        }, {
          value: '20N02',
          label: '四楼'
        }],
        
        //所属楼层选择数据
        options3: [{
          value: '20E01',
          label: '李信'
        }, {
          value: '20E02',
          label: '项羽'
        }, {
          value: '20N01',
          label: '王翦'
        }, {
          value: '20N02',
          label: '韩信'
        }],

        options4: [{
          value: '20E01',
          label: '不收费'
        }, {
          value: '20E02',
          label: '按次收费'
        }, {
          value: '20E03',
          label: '按小时收费'
        }],

      };
    },
    created() {
    },
    mounted() { },
    methods: {
      closePage(){
        console.log('关闭弹窗dialog');
        this.visible = false;
      },
      handleClick(tab, event) {
        console.log(tab, event);
      },
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>